package spring.cloud.eurekaclientproduct.config;

import com.netflix.discovery.endpoint.EndpointUtils;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerListFilter;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.ZonePreferenceServerListFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//全局的微服务配置指定
//@Configuration
public class GlobalConfiguration {

    //服务过滤器
//    @Bean(name = "ribbonServerListFilter")
    public ServerListFilter<Server> serverListFilter(){
        ZonePreferenceServerListFilter filter = new ZonePreferenceServerListFilter();
        filter.setZone(EndpointUtils.DEFAULT_ZONE);
        return filter;
    }

    //负载均衡策略
//    @Bean
    public IRule rule(){
        return new RandomRule();
    }
}
